#define imax INT_MAX
#define imin INT_MIN
#define sz(x) (int((x).size()))
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define a first
#define b second
#define vi vector<int>
#define over(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
struct node {
int val;
node *next;
node *prev;
};
struct VectorHasher {
int operator()(const vector<int> &V) const {
int hash = V.size();
for (auto &i : V) {
hash ^= i + 0x9e3779b9 + (hash << 6) + (hash >> 2);
}
return hash;
}
};
struct PairHasher {
size_t operator()(const pii &x) const { return x.first ^ x.second; }
};
void solve(int s) { cout << s << endl; }
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/* number of test cases, remember to check bounds*/
unsigned int t;
unsigned int n;
#ifndef ONLINE_JUDGE
freopen("../input.txt", "r", stdin);
freopen("../output.txt", "w", stdout);
#endif
int p;
cin >> t >> p;
vector<string> nums;
for (int i = 0; i < t; ++i) { // loops for each case
string s;
cin >> s;
nums.pb(s);
}
ll ans = p/2;
ll cur = 1;
for(int i=sz(nums)-2;i>=0;--i){
if(nums[i] == "half"){
ans += p*cur;
cur *= 2;
}else{
ans += p*cur+p/2;
cur = cur*2+1;
}
}
cout << ans << endl;
return 0;
}
6. Zigzag Conversion | 1612B - Special Permutation |
1481. Least Number of Unique Integers after K Removals | 1035. Uncrossed Lines |
328. Odd Even Linked List | 1219. Path with Maximum Gold |
1268. Search Suggestions System | 841. Keys and Rooms |
152. Maximum Product Subarray | 337. House Robber III |
869. Reordered Power of 2 | 1593C - Save More Mice |
1217. Minimum Cost to Move Chips to The Same Position | 347. Top K Frequent Elements |
1503. Last Moment Before All Ants Fall Out of a Plank | 430. Flatten a Multilevel Doubly Linked List |
1290. Convert Binary Number in a Linked List to Integer | 1525. Number of Good Ways to Split a String |
72. Edit Distance | 563. Binary Tree Tilt |
1306. Jump Game III | 236. Lowest Common Ancestor of a Binary Tree |
790. Domino and Tromino Tiling | 878. Nth Magical Number |
2099. Find Subsequence of Length K With the Largest Sum | 1608A - Find Array |
416. Partition Equal Subset Sum | 1446. Consecutive Characters |
1618A - Polycarp and Sums of Subsequences | 1618B - Missing Bigram |